package com.feicheng.controller;


import com.alibaba.fastjson.JSONObject;
import com.feicheng.base.common.DaoConstant;
import com.feicheng.base.exception.SystemException;
import com.feicheng.base.result.Result;
import com.feicheng.entity.SaleOrderHeader;
import com.feicheng.model.SaleOrderHeaderUser;
import com.feicheng.model.SaleOrderHeaderWithSaleOrderItem;
import com.feicheng.service.ProviderSaleController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 周启博
 * @since 2022-06-27
 */
@RestController
@RequestMapping("/sale_order_header")
public class SaleOrderHeaderController {

    @Autowired
    ProviderSaleController providerSaleController;

    /**
     * 新增销售订单接口
     * @param saleOrderHeaderWithSaleOrderItem    业务参数
     * @autor chunyu.zhao
     * @return
     */
    @PostMapping("/info")
    public Result insertSaleOrder(SaleOrderHeaderWithSaleOrderItem saleOrderHeaderWithSaleOrderItem){
        return providerSaleController.insertSaleOrder(saleOrderHeaderWithSaleOrderItem);
    }

    /**
     *
     * @param current 当前页数
     * @param size   一页几条
     * @param saleOrderHeaderUser
     * @author  唐俊
     * @since 2022-07-05
     * @return
     */
    @GetMapping("/page")
    public Result PageConditionSelect (
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            SaleOrderHeaderUser saleOrderHeaderUser) {
        return providerSaleController.pageConditionSelect(current, size, saleOrderHeaderUser);
    }

    /**
     * 销售订单详情顾客信息修改服务
     * @param saleOrderHeader 用于接取顾客信息主键和顾客主键的对象
     * @return
     * @author yiming.chang
     */
    @PutMapping("/info")
    public Result updateCustomerInfo(
             SaleOrderHeader saleOrderHeader) {
        return providerSaleController.updateCustomerInfo(saleOrderHeader);
    }

    /**
     * 销售订单用户详情页面
     * @param saleId (销售表主键)
     * @author shuoyu.qian
     * @return
     */

    /* 注入销售header的service */
    @GetMapping("/sale_order/info")
    public Result selectSaleOrder(
              Integer saleId
    ) {
        //返回结果集
        return providerSaleController.selectSaleOrder(saleId);

    }
}

